package com.hao.state;
// 测试守护线程
public class testDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();
        Thread thread = new Thread(god);
        thread.setDaemon(true); // 开启守护线程
        thread.start(); // 上帝守护
        new Thread(you).start();
    }
}
// God
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("保佑You");
        }
    }
}
//You
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("第"+i+"天");
        }
        System.out.println("Good Bye !");
    }
}
